package com.ruoyi.community.service.impl;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.community.domain.BbsArticleDetail;
import com.ruoyi.community.mapper.BbsArticleDetailMapper;
import com.ruoyi.community.service.BbsArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BbsArticleServiceImpl implements BbsArticleService {

    @Autowired
    BbsArticleDetailMapper bbsArticleDetailMapper;

    @Override
    public List<BbsArticleDetail> selectBbsArticleDetailList(BbsArticleDetail bbsArticleDetail) {
        return bbsArticleDetailMapper.selectBbsArticleDetailList(bbsArticleDetail);
    }

    @Override
    public int insertSelective(BbsArticleDetail bbsArticleDetail) {
        long userid = SecurityUtils.getUserID();
        bbsArticleDetail.setAuthorid(userid);
        Integer communityid = SecurityUtils.getCommunityId();
        bbsArticleDetail.setCommunityid(communityid);
        return bbsArticleDetailMapper.insertSelective(bbsArticleDetail);
    }

    @Override
    public BbsArticleDetail selectBbsArticleDetailById(Long id) {
        return bbsArticleDetailMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByArticleId(BbsArticleDetail bbsArticleDetail) {
        return bbsArticleDetailMapper.updateByPrimaryKeySelective(bbsArticleDetail);
    }

    @Override
    public List<BbsArticleDetail> selectFavoriteArticleDetailList(Long userid, Integer communityid) {
        return bbsArticleDetailMapper.selectFavoriteArticleDetailList(userid , communityid);
    }
}
